import 'package:app/pages/index/index_controller.dart';
import 'package:app/shared/constants/common.dart';
import 'package:flutter/material.dart';

class CardCom extends StatelessWidget {
  final IndexController controllerArg;

  CardCom({required this.controllerArg, Key? key}) : super(key: key);

  Widget build(context) {
    return Container(
      height: 210,
      child: ListView(
        scrollDirection: Axis.horizontal,
        children: List.generate(
            controllerArg.presenters.length,
            (index) => Container(
                  width: 150,
                  margin: EdgeInsets.only(right: sDefaultMarginPadding * 2),
                  decoration: BoxDecoration(
                      color: Color.fromRGBO(238, 238, 255, 1),
                      borderRadius:
                          BorderRadius.circular(sDefaultMarginPadding * 1.5)),
                  padding: EdgeInsets.only(
                      left: sDefaultMarginPadding * 2,
                      right: sDefaultMarginPadding * 2,
                      top: sDefaultMarginPadding * 3,
                      bottom: sDefaultMarginPadding * 1.5),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Container(
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(23),
                            border: Border.all(color: Colors.white, width: 2)),
                        child: ClipOval(
                          child: Image.network(
                            controllerArg.presenters[index].toJson()["comment"]
                                ["user_profile_image_url"],
                            fit: BoxFit.cover,
                            width: 46,
                            height: 46,
                          ),
                        ),
                      ),
                      SizedBox(
                        height: 16,
                      ),
                      Text(
                        controllerArg.presenters[index].toJson()["comment"]
                            ["user_name"],
                        style: TextStyle(
                            fontWeight: FontWeight.bold,
                            fontSize: 17,
                            overflow: TextOverflow.ellipsis),
                      ),
                      Expanded(
                          child: Padding(
                        padding: EdgeInsets.symmetric(vertical: 10),
                        child: Text(
                          controllerArg.presenters[index].toJson()["comment"]
                              ["text"],
                          style: TextStyle(
                              color: sTextColorDes,
                              overflow: TextOverflow.ellipsis),
                        ),
                      )),
                      Container(
                          padding: EdgeInsets.all(3),
                          margin: EdgeInsets.symmetric(
                              vertical: sDefaultMarginPadding * 1.5,
                              horizontal: 0),
                          width: 70,
                          decoration: BoxDecoration(
                              color: Colors.white,
                              borderRadius: BorderRadius.circular(
                                  sDefaultMarginPadding * 1.5)),
                          child: Row(
                            children: [
                              Icon(Icons.add),
                              Text(
                                '关注',
                                style: TextStyle(
                                    color: sTextColor,
                                    fontWeight: FontWeight.bold),
                              )
                            ],
                          ))
                    ],
                  ),
                )),
      ),
    );
  }
}
